package com.personal.gateway.custom.customEnum.flinkCommandEnum;

import com.personal.gateway.flinkAllCommand.configurationOption.ConfigurationOption;
import com.personal.gateway.flinkAllCommand.configurationOption.configurationType.ConfigurationTypeEnumInterface;
import lombok.Getter;

import javax.annotation.Nonnull;

/**
 * @author BigHead
 * @date 2021/12/30 14:37
 * @description DockerPullSecretsEnum
 */
@Getter
public enum DockerPullPolicyEnum implements ConfigurationTypeEnumInterface {

    /**
     * 不存在则拉取镜像
     */
    IF_NOT_PRESENT("IfNotPresent"),
    /**
     * 总是拉取镜像
     */
    ALWAYS("Always"),
    /**
     * 从不拉取镜像
     */
    NEVER("Never");

    public final static Class<Enum<? extends ConfigurationTypeEnumInterface>> DOCKER_PULL_POLICY_TYPE_CLASS = (Class<Enum<? extends ConfigurationTypeEnumInterface>>) (Class<?>) DockerPullPolicyEnum.class;


    private final String dockerPullPolicy;

    DockerPullPolicyEnum(String dockerPullPolicy) {
        this.dockerPullPolicy = dockerPullPolicy;
    }

    @Override
    public String getShowValue() {
        return name();
    }

    @Override
    public String getSelectValue() {
        return dockerPullPolicy;
    }

    @Override
    public boolean checkExist(@Nonnull String... values) {
        if (values.length == 1){
            return dockerPullPolicy.equals(values[0]);
        }
        return false;
    }

    @Override
    public boolean checkExist(ConfigurationOption<?, ?> configurationOption, @Nonnull String... values) {
        return false;
    }

    @Override
    public boolean checkExampleValue(ConfigurationOption<?, ?> configurationOption) {
        return false;
    }
}
